package com.cn.chaomeng.controller;

import com.cn.chaomeng.model.Orders;
import com.cn.chaomeng.service.ExChangeService;
import com.cn.chaomeng.vo.app.OrderInfosVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author 范中燊
 * @version V1.0
 * @Title: ${file_name}
 * @Package ${package_name}
 * @Description: TODO
 * @date ${date} ${time}
 */
@Controller
@RequestMapping("/")
public class EmptyContrller
{

    @Autowired
    private ExChangeService exChangeService;

    /**
     * 结算页面
     *
     * @param openId
     * @param orderid
     * @return
     * @throws IOException
     */
    @RequestMapping("/hjpay")
    public ModelAndView payer(@RequestParam String openId, @RequestParam int orderid)
        throws IOException
    {
        Map<String, Object> resMap = new HashMap<String, Object>();

        Orders orders = exChangeService.getOrdersByKey(orderid);

        List<OrderInfosVO> orderInfosVOs = exChangeService.getOrderInfos(orderid);

        resMap.put("orders", orders);
        resMap.put("openId", openId);
        resMap.put("orderInfos", orderInfosVOs);

        return new ModelAndView("app/payer", resMap);
    }

}
